import Vue from "vue";
import "babel-polyfill";
import Vuex from "vuex";
import { language } from "@/config/base";
import permission from "./permission";
Vue.use(Vuex);

let store = new Vuex.Store({
  state: {
    user: localStorage["user"] ? JSON.parse(localStorage["user"]) : "",
    locale: localStorage.language || language, //默认语言
    // 折叠
    isCollapse: false,
    // 左侧菜单数据
    menuList:[]
  },
  getters: {},
  mutations: {
    SET_USER(state, data) {
      state.user = data;
    },
    setLocale(state, data) {
      state.locale = data;
      localStorage.setItem("language", data);
    },
    SET_COLLAPSE(state) {
      state.isCollapse = state.isCollapse?false:true;
    },
    SET_MENU_LIST(state, data) {
      state.menuList = data
    },
  },
  actions: {},
  modules: {
    permission
  }
});
export default store;
